package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.CarDao;
import entity.CarInfo;

public class UpdateCarServlet extends HttpServlet {
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		

		CarInfo car = new CarInfo();
		car.setCarId(Integer.parseInt(request.getParameter("carid")));
		car.setUserName(request.getParameter("username"));
		car.setCarName(request.getParameter("carname"));
		car.setCarType(request.getParameter("cartype"));
		car.setCarColor(request.getParameter("carcolor"));
		car.setCarCard(request.getParameter("carcard"));

		new CarDao().update(car);
		response.sendRedirect("./listCar");

	}

}
